package com.ht.shop.service.impl;

import com.ht.shop.dao.AddressDao;
import com.ht.shop.dao.impl.AddressDaoImpl;
import com.ht.shop.pojo.TbAddress;
import com.ht.shop.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AddressServiceImpl implements AddressService {
    private AddressDao addressDao ;
    @Autowired
    public void setAddressDao(AddressDao addressDao) {
        this.addressDao = addressDao;
    }

    @Override
    public List<TbAddress> findAllAddressByUid(long uid) {
        return addressDao.findAllAddressByUid(uid);
    }

    @Override
    public void  addAddress(String detail, String name, String phone ,long uid) {
        addressDao.addAddress(detail,name,phone,uid);

    }

    @Override
    public void updateAddress(String detail, String name, String phone, long id) {
        addressDao.updateAddress(detail,name,phone,id);
    }

    @Override
    public void deleteAddressById(long id) {
        addressDao.deleteAddressById(id);
    }

    @Override
    public List<TbAddress> findAllAddress() {
        try {
            List<TbAddress> allAddressById = addressDao.findAllAddressById();
            return allAddressById;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
